home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 25
/
Mac Magazin and MacEasy Magazine CD - Issue 25.iso
/
Grafik & Text
/
Alpha
/
Tcl
/
SystemCode
/
menus.tcl
< prev
next >
Wrap
Text File
|
1996-08-16
|
10KB
|
551 lines
# My menus.
if !$alphaLite {
menu -n File -p fileMenuProc {
"/Nnew"
"/Oopen…"
{menu -n recent {}}
"<S/Wclose"
"<S<I<O/WcloseAll"
"(-"
"<S/Ssave"
"<S<I<O/SsaveAll"
"<SsaveACopyAs…"
"<SsaveAs…"
"<E<SrevertToBackup"
"<Srevert"
"(-"
"<S/Y<Oshell"
"<S/Y<U<Ocalculator"
"<S/Y<B<OtoolserverShell"
"(-"
"pageSetup…"
{menu -n print {}}
"(-"
"/Qquit"
}
menu -n Edit {
"/Zundo"
"/Z<I<Oredo"
"/Lload"
"(-"
"/X<Scut"
"/X<S<I<Ocut&Append"
"/C<Scopy"
"/C<S<I<Ocopy&Append"
"/V<Spaste"
"/V<S<I<OpastePop"
"/A<SselectAll"
"/A<S<I<OselectParagraph"
"clear"
"(-"
{menu -n emacs {}}
"/`<Stwiddle"
"/`<S<I<OtwiddleWords"
"(-"
{/[<SshiftLeft}
{/[<S<I<OshiftLeftSpace}
{/]<SshiftRight}
{/]<S<I<OshiftRightSpace}
"/Bbalance"
}
menu -n Text {
"/I<SfillParagraph"
"/I<S<O<IwrapParagraph"
"/I<S<O<I<UsentenceParagraph"
"/U<S<OfillRegion"
"/U<S<I<OwrapRegion"
"/U<S<O<I<UsentenceRegion"
"<E<SparagraphToLine"
"<SlineToParagraph"
"(-"
"<SreverseSort"
"<SsortLines"
"/L<I<OspellcheckWindow"
"(-"
"zapInvisibles"
"<SspacesToTabs"
"<StabsToSpaces"
"<S<EindentRegion"
"<SindentLine"
"<E<SdowncaseRegion"
"<SupcaseRegion"
"(-"
{menu -n Strings {
"<SremovePrefix"
"<SinsertPrefix"
"<S<EremoveSuffix"
"<SinsertSuffix"
"setPrefix"
"setSuffix"
}}
"/D<ScommentLine"
"/D<S<I<OuncommentLine"
"<SuncommentBox"
"<ScommentBox"
"<S<EuncommentParagraph"
"<ScommentParagraph"
"(-"
"/=markHilite"
{menu -n namedMarks -p namedMarkProc {
"/K<Oset…"
"/K<I<Ogoto…"
"remove…"
"(-"
"sort"
"sortByPosition"}}
{menu -n unnamedMarks -p unnamedMarkproc {
"set…"
"exchangePointAndMark"}}
}
menu -n "Utils" {
{menu -n fileUtils {
"insertPathName…"
"insertFile…"
"fileRemove…"
"fileInfo…"
"wordCount"
"textToAlpha"}}
{menu -m -n compare -p compareProc {
"Windows"
"Files…"
"Directories…"}}
{menu -n asciiEtc {
"quoteChar"
"(-"
"keyCode"
"keyAscii"
"getAscii"
"insertAscii"}}
{menu -n KbdMacros {
"/qstartKeyboardMacro"
"/rendKeyboardMacro"
"/sexecuteKeyboardMacro"
"dumpMacro"}}
"(-"
"sendUrl"
{menu -m -n switchTo -p switchProc {}}
"(-"
"/M<I<OmatchingLines"
"gotoMatch"
"nextMatch"
"(-"
"/jcmdDoubleClick"
}
menu -n Config {
{menu -n "Current Mode" -p modeOptions {
"menus…"
"flags…"
"editPrefs"
"loadPrefs…"
"describeMode"
"(-"
"/m<Uchange…"
}}
{menu -n Global -p globalOptions {
"menus…"
"flags…"
"editPrefs"
"listBindings"
"listFunctions"}}
"suffixMappings…"
"/kdescribeBinding"
"viewSavedSetting…"
"removeSavedSetting…"
"(-"
{menu -n appPaths {}}
{menu -m -n install -p installProc {
"Electric Alias"
"(-"
"LaTeX 2e"
"LaTeX 2.09"}}
"deconstruct…"
"(-"
"/lsetFontsTabs…"
{menu -n redefineColors -p colorProc {
foreground
background
"(-"
blue
cyan
green
magenta
red
white
yellow
"(-"
color_9
color_10
color_11
color_12
color_13
color_14
color_15}}
}
menu -n $winMenu -p menuWin {
"//<Szoom"
"//<S<I<OsinglePage"
"<S/;chooseAWindow"
"/I<Biconify"
{menu -n arrange -p winTileProc {
"/Jvertically^1"
"/J<O<Ihorizontally^2"
"/J<B<OunequalVert^6"
"/J<B<I<OunequalHor^5"
"(-"
{menu -n other {
{bufferOtherWindow}
{iconify}
{nextWin}
{nextWindow}
{prevWindow}
{shrinkFull}
{shrinkHigh}
{shrinkLeft}
{shrinkLow}
{shrinkRight}
{singlePage}
{swapWithNext}
{zoom}
}}}}
"(-"
"/msplitWindow"
"/otoggleScrollbar"
"(-"
}
} else {
menu -n File -p fileMenuProc {
"/Nnew"
"/Oopen…"
{menu -n recent {}}
"<S/Wclose"
"<S<I<O/WcloseAll"
"(-"
"<S/Ssave"
"<S<I<O/SsaveAll"
"<SsaveAs…"
"<E<SrevertToBackup"
"<Srevert"
"(-"
"pageSetup…"
"/Pprint…"
"(-"
"/Qquit"
}
menu -n Edit {
"/Zundo"
"/Z<I<Oredo"
{menu -n emacs {}}
"(-"
"/X<Scut"
"/X<S<I<Ocut&Append"
"/C<Scopy"
"/C<S<I<Ocopy&Append"
"/V<Spaste"
"/V<S<I<OpastePop"
"/A<SselectAll"
"/A<S<I<OselectParagraph"
"clear"
"(-"
"/=selectLast"
"/`<Stwiddle"
"/`<S<I<OtwiddleWords"
}
menu -n Text {
"/I<SfillParagraph"
"/I<S<O<IwrapParagraph"
"/I<S<O<U<I<BsentenceParagraph"
"/U<S<OfillRegion"
"/U<S<I<OwrapRegion"
"/U<S<O<U<I<BsentenceRegion"
"<E<SupcaseRegion"
"<SdowncaseRegion"
"(-"
"<SreverseSort"
"<SsortLines"
"/L<I<OspellcheckWindow"
"zapInvisibles"
"<SspacesToTabs"
"<StabsToSpaces"
"(-"
"/D<ScommentLine"
"/D<S<I<OuncommentLine"
"<SuncommentBox"
"<ScommentBox"
"<S<EuncommentParagraph"
"<ScommentParagraph"
"(-"
"textToAlpha"
}
menu -n Config {
{menu -n "Current Mode" -p modeOptions {
"menus…"
"flags…"
"editPrefs"
"loadPrefs…"
"describeMode"
"(-"
"/m<Uchange…"
}}
{menu -n Global -p globalOptions {
"menus…"
"flags…"
"editPrefs"
"listBindings"
"listFunctions"}}
"suffixMappings…"
"(-"
"/kdescribeBinding"
"viewSavedSetting…"
"removeSavedSetting…"
"(-"
"/lsetFontsTabs…"
}
menu -n $winMenu -p menuWin {
"//<Szoom"
"//<S<I<OsinglePage"
"<S/;chooseAWindow"
"/I<Biconify"
{menu -n arrange -p winTileProc {
"/Jvertically^1"
"/J<O<Ihorizontally^2"
"/J<B<OunequalVert^6"
"/J<B<I<OunequalHor^5"
"(-"
}}
"(-"
"/isetFontsTabs…"
"/msplitWindow"
"/otoggleScrollbar"
"(-"
}
}
proc fileMenuProc {menu item} {
if {$item == "open"} {
findFile
} elseif {$item == "close"} {
killWindow
} else {
$item
}
}
menu -n Search {
"/F<Sfind…"
"/F<S<I<OsearchStart"
"/G<SfindAgain"
"/G<S<I<OfindAgainBackward"
"/MfindInNextFile"
"/E<SenterSearchString"
"/E<S<I<OenterReplaceString"
"(-"
"/S<BquickFind"
"/R<BreverseQuickFind"
"(-"
"/Rreplace"
"/Hreplace&FindAgain"
"<S/R<O<IreplaceAll"
"<S/R<O<I<BreplaceInFileset"
"(-"
"/,<BpushPosition"
"/.<BpopPosition"
"/G<IgotoLine"
}
proc pushPosition {} {pushMark}
proc popPosition {} {popMark}
# {menu -n NamedClipboards -p namedClipMenuProc {"copy…" "cut…" "paste…"}}
# {menu -n registers { pointToRegister jumpToRegister }}
proc namedMarkProc {menu item} {
switch $item {
"markFile" {markFile; message "File marked."}
"set" {setNamedMark}
"goto" {gotoFileMark}
"remove" {removeNamedMark}
"sort" {sortMarksFile}
"sortByPosition" {orderMarks}
}
}
proc unnamedMarkproc {menu item} {
switch $item {
"set" {setMark}
"exchangePointAndMark" {exchangePointAndMark}
"hilite" {markHilite}
}
}
proc installProc {menu item} {
switch $item {
"Electric Alias" {loadElectricAlias}
"LaTeX 2.09" {loadLaTeX}
"LaTeX 2e" {loadLaTeX}
}
}
proc compareProc {menu item} {
catch {compare$item} msg
message $msg
}
proc namedClipMenuProc {menu item} {
switch $item {
"copy" "copyNamedClipboard"
"cut" "cutNamedClipboard"
"paste" "pasteNamedClipboard"
}
}
proc colorProc {menu item} {
global colorInds modifiedArrVars
if {[info exists colorInds($item)]} {
set color [eval [list colorTriple "New \"$item\":"] $colorInds($item)]
} else {
switch $item {
foreground { set inds "0 0 0" }
background { set inds "65535 65535 65535" }
blue { set inds "0 0 65535" }
cyan { set inds "61404 11464 34250" }
green { set inds "1151 33551 8297" }
magenta { set inds "44790 1591 51333" }
red { set inds "65535 0 0" }
white { set inds "65535 65535 65535" }
yellow { set inds "61834 64156 12512" }
default { set inds "65535 65535 65535" }
}
set color [eval [list colorTriple "New \"$item\":"] $inds]
}
eval setRGB $item $color
set colorInds($item) $color
lappend modifiedArrVars colorInds
}
#===============================================================================
proc helpMenu {item} {
global HOME
if {$item == "Alpha Manual"} {
edit -r "$HOME:Help:Manual"
} else {
edit -r "$HOME:Help:$item"
}
}
if {![catch {glob "$HOME:Help:*"} files]} {
set men { "Alpha Manual" "Alpha Commands" "Tcl Commands" "(-" "Quick Start" "Readme" "Changes" "(-" }
foreach f [lsort -ignore $files] {
set f [file tail $f]
if {[lsearch $men $f] < 0} {
lappend men $f
}
}
foreach f $men {
addHelpMenu $f
}
unset men
}
#===============================================================================
proc buildSwitches {} {
global switchApps
menu -m -n switchTo -p switchProc {"<O<I/NNow…" "Add…" "Remove…" "(-"}
if {[info exists switchApps] && [llength $switchApps]} {
foreach app $switchApps {
lappend names [file tail $app]
}
foreach name [lsort -ignore $names] {
addMenuItem -m -l "blah" switchTo $name
}
}
}
proc switchProc {menu name} {
global switchTo switchApps
if {$name == "Add"} {
set fname [getfile "Pick an app:"]
lappend switchApps $fname
addDef switchApps $switchApps
buildSwitches
} elseif {$name == "Remove"} {
foreach app $switchApps {
lappend apps [file tail $app]
}
set name [listpick -p "Remove which app?" $apps]
if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
set switchApps [lreplace $switchApps $ind $ind]
addDef switchApps $switchApps
buildSwitches
}
} elseif {$name == "Now"} {
switchApp
} else {
if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
if {[catch {switchTo $name}]} {
launch -f [lindex $switchApps $ind]
}
}
}
}
proc winTileProc {menu item} {
win$item
}
# "tiled^3"
# "overlay^4"
# We may be reloading, so add whatever windows we have
if {[info exists winNameToNum]} {
set nms [array names winNameToNum]
foreach name $nms {
regexp {[^:]*$} $name item
set num $winNameToNum($name)
if {$num < 10} {
addMenuItem -m $winMenu /$num$item
} else {
addMenuItem -m $winMenu $item
}
}
}
insertMenu "File"
insertMenu "Edit"
insertMenu "Text"
insertMenu "Search"
catch {insertMenu "Utils"}
#enableMenuItem NamedClipboards paste off
insertMenu "Config"
insertMenu $winMenu